﻿using GamFi.API.Application.Contracts.Chains.GetChainById;
using GamFi.API.Application.Contracts.Chains.GetChains;
using GamFi.API.Application.Features.Queries.Chain.GetChainById;
using GamFi.API.Application.Features.Queries.Chain.GetChains;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace GamFi.API.WEB.Controllers;

[ApiController]
[Route("api/[controller]")]
public class ChainController(IMediator mediator): ControllerBase
{
    /// <summary>
    /// Возвращает все чейны
    /// </summary>
    /// <param name="cancellationToken"></param>
    /// <returns>Все чейны</returns>
    [HttpGet("GetChains")]
    public async Task<GetChainsResponse> GetChains(CancellationToken cancellationToken)
        => await mediator.Send(new GetChainsQuery(), cancellationToken);

    /// <summary>
    /// Возвращает чейн по ИД
    /// </summary>
    /// <param name="id"></param>
    /// <param name="cancellationToken"></param>
    /// <returns>Чейн по ИД</returns>
    [HttpGet("GetChainById/{id:guid}")]
    public async Task<GetChainByIdResponse> GetChainById(Guid id, CancellationToken cancellationToken)
        => await mediator.Send(new GetChainByIdQuery(id), cancellationToken);
}